InMemoryDatabaseCache

internal object InMemoryDatabaseCache

Provides an in-memory cache for in-memory databases.

On iOS, SQLiter uses "file:{name}?mode=memory&cache=shared" for named in-memory databases, which means databases with the same name share data. This cache allows us to:

  1. Reuse database instances across calls with the same userId

  2. Properly close and clear databases between tests to ensure isolation

When clearEntry is called, the database driver is closed, which causes SQLite to automatically delete the shared in-memory database (since it's the last connection).

Functions

Link copied to clipboard
fun clearEntry(userIDEntity: <Error class: unknown class>): Boolean

Clears an entry from the cache based on the provided userIDEntity. This also closes the database driver, which causes SQLite to delete the shared in-memory database.

Link copied to clipboard
fun getOrCreate(userIDEntity: <Error class: unknown class>, create: () -> <Error class: unknown class>): <Error class: unknown class>